<?


IF ($uid){
   $query="SELECT user_name FROM sdusers where user_id=$uid";
   IF ($resultat=mysql_query($query)){
      $tmp2=mysql_fetch_array($resultat);
      $name=$tmp2[0];
      }
}

TITRE('Envois de message');


$MESSAGE[0]=addslashes(MESSAGE_01('Le champ destinataire est vide, veuillez le remplir.'));
$MESSAGE[1]=addslashes(MESSAGE_01('Le champ sujet est vide, veuillez le remplir.'));
$MESSAGE[2]=addslashes(MESSAGE_01('Le message est vide, veuillez le remplir.'));

$TMP_PAGE="<script language=\"javascript\">
var contenu0 =\"$MESSAGE[0]\";
var contenu1 =\"$MESSAGE[1]\";
var contenu2 =\"$MESSAGE[2]\";

function SLT_FRIEND(text){
	document.poster.destination.value=text;
}

function envoyer(){
        if (document.poster.message.value.length==0){
           changecontenu(contenu2,'div_inner_message'); div_app('div_message');
            return false;
        }else if  (document.poster.sujet.value.length==0){
            changecontenu(contenu1,'div_inner_message'); div_app('div_message');
               return false;
        }else if  (document.poster.destination.value.length==0){
              changecontenu(contenu0,'div_inner_message'); div_app('div_message');
               return false;
        }else{

               return true;
        }
}
</script> ";

$TMP_PAGE.="<form name=\"poster\" id=\"poster\" method=\"post\"  action=\"site/test/include.php\" target=\"frame_test\" OnSubmit=\"return envoyer();\">";

$TMP_PAGE.=" <TABLE width=\"95%\" BORDER=\"0\" align=\"center\" CELLPADDING=\"0\" CELLSPACING=\"0\"><TR>
  <td width=\"25%\"><font class=\"texte_forum\">Nom du destinataire : </font></td>
            <td width=\"25%\"><input name=\"destination\" type=\"text\" id=\"destination\" value=\"$name\"></td>
            <td width=\"25%\"><div align=\"right\"></div></td>
            <td width=\"25%\">";

$query ="SELECT user_friends FROM sdusers WHERE user_id=$_USER_ID";
$resultat=mysql_query($query);
$tmp=mysql_fetch_array($resultat);
     
$list_ami=$tmp[0];

 //La liste
//----------
IF (!empty($list_ami)){ 

	   
	   $tmp_x=explode("/",$list_ami);
	  $nbr=count($tmp_x); $nbr--;
   
 		FOR($i=0;$i<$nbr;$i++){
			$tmp_x2=explode("-",$tmp_x[$i]);

 			$TMP_USER[$i]=" user_id=$tmp_x2[1]";			

		}//Fin du FOR($i=0;$i<$nbr;$i++){
		$tmp_query=implode($TMP_USER," OR ");


      $TMP_PAGE.="<BR><select name=\"jeu\" CLASS=\"SELECT_1\" onChange=\"SLT_FRIEND(this.form.jeu.options[this.form.jeu.selectedIndex].value)\">";
      //$query ="SELECT user_name FROM cdn_users WHERE $tmp_query ORDER BY user_name";
      $TMP_PAGE.="<option  value=\"\"  >Choississez</option>";
      $query ="SELECT user_name FROM sdusers WHERE $tmp_query ORDER BY user_name";
      $resultat=mysql_query($query);
       WHILE ($tmp=mysql_fetch_array($resultat)){
              $TMP_PAGE.="<option  value=\"$tmp[0]\"  >$tmp[0]</option>";
       }//Fin du   WHILE ($tmp=mysql_fetch_array($resultat)){
       $TMP_PAGE.="</select>";
}
    $TMP_PAGE.="</td></tr></table><BR>";



REQUIRE("site/forum/textarea2.php");



    $TMP_PAGE.="<input name=\"p\" type=\"hidden\" id=\"p\" value=\"send_mp\">";
    $TMP_PAGE.="<input name=\"SID\" type=\"hidden\" id=\"SID\" value=\"$SID\">";
    $TMP_PAGE.="<CENTER><input name=submit type=submit value=envoyer name=soumettre></CENTER></form>";
    $TMP_PAGE=TDF_M($TMP_PAGE);

echo $TMP_PAGE;
  
?>


